<include file="header" />
<div class="wraper">
	<div class="load">
		<img class="load-bee" src="/assets/base/laundry/images/load-bee.png">

	</div>
	<!-- <div class="head clearfix">
		<a href="{BEESCRM::U('/Base/laundry/index',array('laundryId'=>$laundryId))}" class="iconfont icon-shouye pull-right text-right"></a>
		<span class="head-name pull-right">智能洗衣</span>
	</div> -->
	<!-- <div class="wash-machine"><img src="/assets/base/laundry/images/washing.gif"/></div> -->
	<!-- <p class="battery text-center">正在洗衣...</p>
	<p class="battery-time text-center"> -->

    <!--<volist name="adInfo" id="vo">-->
        <!--<div class="banner">-->
            <!--<div class="swiper-container">-->
                <!--<div class="swiper-wrapper" style="height:200px;">-->
                    <!--<a href="{BEESCRM:$vo.url}">{BEESCRM:$vo.content}</a>-->
                <!--</div>-->
            <!--</div>-->
        <!--</div>-->
    <!--</volist>-->


    <!--<div class="rest-time">-->
        <!--<p>提醒您　洗衣已用</p>-->
        <!--<p><span id="washing-time"></span></p>-->
    <!--</div>-->

<!--    <a href="{BEESCRM:$adInfo[0]['url']}" class="advert">
        {BEESCRM:$adInfo[0]['content']}
        <div class="rest-time">
            <p>提醒您　洗衣已用</p>
            <p><span id="washing-time"></span></p>
        </div>
    </a>-->
	<div class="banner advert">
		<div class="swiper-container">
			<div class="swiper-wrapper">
				<if condition="count($adInfo) gt 0">
					<volist name="adInfo" id="vo">
						<div class="swiper-slide"><a href="{BEESCRM:$vo['url']}">{BEESCRM:$vo['content']}</a></div>
					</volist>
				<else/>
					<div class="swiper-slide">
						<a href="http://mp.weixin.qq.com/s?__biz=MzAxMTA5NDkyNg==&mid=505197819&idx=1&sn=eb330dfe96460bfd9966602c51be4370#rd">
							<img src="/assets/base/laundry/images/advert.jpg"/>
						</a>
					</div>
				</if>				
			</div>
			<div class="swiper-pagination"></div>
			<div class="rest-time">
				<p>提醒您　洗衣已用</p>
				<p><span id="washing-time"></span></p>
			</div>
		</div>
	</div>

	<p class="battery-time text-center">
		本次预冻结时长：{BEESCRM:$data.freezing_time}分钟<br>
		开始时间：{BEESCRM:$data.start_time|date="Y-m-d H:i",###}<br>
		<!-- 已洗衣时长：<span id="washing-time"></span><br> -->
		线下编号：{BEESCRM:$data.line_num}
	</p>
	<div class="btn-box sm-btn">
		<a href="javascript:void(0)" class="btn end-btn" >结束洗衣</a>
	</div>
	<div class="btn-box white-btn">
		<a href="javascript:void(0)" class="btn laundry">我还要洗</a>
	</div>
	<div class="bottom-box">
		<p class="copyright">杭州青橄榄网络技术有限公司 技术支持</p>
	</div>
</div>
<input type="hidden" value="{BEESCRM:$data.start_time}000" id="start-timestamp">
<input type="hidden" value="{BEESCRM:$data.terminal_id}" id="terminal_id">
<input type="hidden" value="{BEESCRM:$data.laundry_log_id}" id="laundry_log_id">
<include file="commonJS" />
<include file="share_header" />
<script>
	var height = $(document).height();
	var bottombox_height = $('.bottom-box').outerHeight();
	$('.wraper').css("minHeight",height);
	$('.wraper').css("paddingBottom",bottombox_height);
	var swiper = new Swiper('.banner .swiper-container', {
//		pagination: '.banner .swiper-pagination',
paginationClickable: true,
spaceBetween: 30,
centeredSlides: true,
autoplay: 2500,
autoplayDisableOnInteraction: false
});
	$(window).load(function(){
		$('.load').hide();
	});
	$(function () {
		var startTime = $('#start-timestamp').val() || $.now();
		(function timer() {
			timeDiff(startTime);
			setTimeout(function () {
				timer();
			}, 1000);
		})();

		function timeDiff(startTime) {
			var diffTime = $.now() - startTime;

			var hour = Math.floor(diffTime/(3600*1000));

			var minutes = Math.floor((diffTime - hour*60*60*1000)/(60*1000));

			var seconds = Math.floor((diffTime - hour*60*60*1000 - minutes*60*1000)/1000);

			$('#washing-time').text(('0' + hour).slice(-3) + '小时 ' + ('0' + minutes).slice(-2) + '分 ' + ('0' + seconds).slice(-2) + '秒 ');

		}
		$(document).on('click','.end-btn',function(){
			$.confirm('您确认要停止洗衣么',drop);
			function drop(){
				var data={};
				data.terminal_id=$('#terminal_id').val();
				data.laundry_log_id=$('#laundry_log_id').val();
				if(!data.laundry_log_id || !data.terminal_id){
					$.alert('error','参数错误');return;
				}
				var json={};
				json.method='post';
				json.type='json';
				json.url="{BEESCRM::U('/base/Laundry/switch_off',array('laundryId'=>$laundryId))}";
				json.data=data;
				$.getAjax(json,true,reload,'');
			}
			function reload(){
				setTimeout('location.href="{BEESCRM::U('/base/laundry/index',array('laundryId'=>$laundryId))}"',3000);
			}
		});

		var A=setInterval(function(){
			var data={};
			var json={};
			data.laundry_log_id=$('#laundry_log_id').val();
			json.method='post';
			json.type='json';
			json.url="{BEESCRM::U('/base/laundry/checkCharge',array('laundryId'=>$laundryId))}";
			json.data=data;
			$.getAjax(json,false,update,'');
		},10000);
		function update(data){
			var status=data.status;
			if(status=='S'){
				setTimeout('location.href="{BEESCRM::U('/base/laundry/index',array('laundryId'=>$laundryId))}"',3000);
			}
		}
	})
    //调起二维码扫一扫
    $(document).on('click','.laundry',function(){
    	wx.scanQRCode({
			needResult: 0, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
			scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码，默认二者都有
			success: function (res) {
				var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
			}
		});
    });
</script>
</body>
</html>